home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C++
/
Applications
/
Mic-1 v1.0
/
Project and Source
/
Source
/
mic_data_path.h
< prev
next >
Wrap
Text File
|
1996-05-17
|
5KB
|
177 lines
#ifndef _MIC_DATA_PATH_
#define _MIC_DATA_PATH_
#include <iostream.h>
#include "mic_main.h"
class MARClass;
class MBRClass;
class ScratchPadClass;
class ALUClass;
class AMUXClass;
class ShifterClass;
class A_LatchClass;
class B_LatchClass;
class MARClass
{
private:
unsigned short word;
short mar_enabled;
public:
MARClass() {word = 0; mar_enabled = false;}
void input_B_Latch (unsigned short newWord) {if (mar_enabled) word = (newWord & 0x0FFF);}
void input_MIR (short enable) {mar_enabled = enable;}
void output (Mic_1_Class& Mic);
friend ostream& operator << (ostream& s, MARClass& m);
};
class MBRClass
{
private:
unsigned short word;
short read_enabled;
short write_enabled;
short mbr_enabled;
public:
MBRClass() {word = 0; read_enabled = false;
write_enabled = false; mbr_enabled = false;}
void input_Memory (unsigned short newWord);
void input_Shifter (unsigned short newWord);
void input_MIR_read (short read) {read_enabled = read;}
void input_MIR_write (short write) {write_enabled = write;}
void input_MIR_enable (short enable) {mbr_enabled = enable;}
void output (Mic_1_Class& Mic);
friend ostream& operator << (ostream& s, MBRClass& m);
};
class ScratchPadClass
{
private:
unsigned short registers[16];
unsigned short shifter_word;
unsigned short selection_a;
unsigned short selection_b;
unsigned short selection_c;
short c_enabled;
public:
ScratchPadClass();
void input_MIR_enable (short newEnable) {c_enabled = newEnable;}
void input_MIR_A (Mic_1_Class& Mic, unsigned short a) {selection_a = a; output(Mic);}
void input_MIR_B (Mic_1_Class& Mic, unsigned short b) {selection_b = b; output(Mic);}
void input_MIR_C (unsigned short c) {selection_c = c;}
void input_Shifter (unsigned short new_shifter_word)
{
shifter_word = new_shifter_word;
if (c_enabled)
registers[selection_c] = shifter_word;
}
void output (Mic_1_Class& Mic);
friend ostream& operator << (ostream& s, ScratchPadClass& scratch);
};
class AMUXClass
{
private:
short from_mbr;
unsigned short a_latch_word;
unsigned short mbr_word;
public:
AMUXClass() {from_mbr = false; a_latch_word = false; mbr_word = 0;}
void input_MBR (Mic_1_Class& Mic, unsigned short new_mbr_word)
{
mbr_word = new_mbr_word;
if (from_mbr)
output(Mic);
}
void input_A_Latch (Mic_1_Class& Mic, unsigned short new_a_latch_word)
{
a_latch_word = new_a_latch_word;
if (!from_mbr)
output(Mic);
}
void input_MIR (short new_from_mbr) {from_mbr = new_from_mbr;}
void output (Mic_1_Class& Mic);
friend ostream& operator << (ostream& s, AMUXClass& a);
};
class ALUClass
{
private:
short check; // to prevent unnecessary work, check makes sure both pipes have been received
unsigned short b_latch_word;
unsigned short amux_word;
unsigned short operation;
short negative;
short zero;
public:
ALUClass() {check = b_latch_word = amux_word = operation = negative = zero = 0;}
void input_AMUX(Mic_1_Class& Mic, unsigned short new_amux_word)
{
amux_word = new_amux_word;
if ((operation == 2) || (operation == 3))
{
output(Mic);
check = 0;
}
else
{
if (check == 1)
{output(Mic); check = 0;}
else (check = 1);
}
}
void input_B_Latch(Mic_1_Class& Mic, unsigned short new_b_latch_word)
{
b_latch_word = new_b_latch_word;
if ((operation == 0) || (operation == 1))
{
if (check == 1)
{output(Mic); check = 0;}
else (check = 1);
}
else
{
check = 0;
}
}
void input_MIR(unsigned short new_operation) {operation = new_operation;}
void output (Mic_1_Class& Mic);
friend ostream& operator << (ostream& s, ALUClass& a);
};
class ShifterClass
{
private:
unsigned short word;
unsigned short option;
public:
void input_ALU (Mic_1_Class& Mic, unsigned short newWord);
void input_MIR (unsigned short newOption) {option = newOption;}
void output (Mic_1_Class& Mic);
friend ostream& operator << (ostream& s, ShifterClass& a);
};
class A_LatchClass
{
private:
unsigned short word;
public:
A_LatchClass() {word = 0;}
void input_ScratchPad (unsigned short newWord) {word = newWord;}
void output (Mic_1_Class& Mic);
friend ostream& operator << (ostream& s, A_LatchClass& a);
};
class B_LatchClass
{
private:
unsigned short word;
public:
B_LatchClass() {word = 0;}
void input_ScratchPad (unsigned short newWord) {word = newWord;}
void output (Mic_1_Class& Mic);
friend ostream& operator << (ostream& s, B_LatchClass& b);
};
#endif